package travel;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.print.attribute.standard.Fidelity;

import swing.Giyuc;
import swing.GiyucEvent;

public class Travel_Information_DAO {
	//SQL문 모음
	String place;
	public String DRV = "oracle.jdbc.driver.OracleDriver";
	public String URL = "jdbc:oracle:thin:koby99/koby99@112.216.253.125:1521:xe";
	
	public String insertSQL = " insert into travel_Informetion values ( 'tc - '|| to_char(travel.nextval),?,?,?,?,?,?,?,?,?) ";
	//관리자
	
	public String arrayAddTest = "select *from travel_Informetion";
	//나의여행
	
//	public String giyicSQL = "select ti.travel_place, ti.travel_duration, ti.travel_price, ti.travel_introduction, ti.travel_notice, ti.travel_votes" +
//			" from travel_Informetion ti, region rg where rg.region_name ="+Giyuc.btname+" order by ti.travel_place";
	public String giyicSQL = "select ti.travel_place, ti.travel_duration, ti.travel_price, ti.travel_introduction, ti.travel_notice, ti.travel_votes "+
			"from travel_Informetion ti, region rg where RG.REGION_CODE = TI.REGION_CODE and rg.region_name = '"+GiyucEvent.title +"' order by rg.region_name";
	public String votesIMSQL = "select ti.travel_image, ti.travel_votes, rg.region_name, ti.travel_place "
			+ "FROM travel_informetion ti ,region rg  where ti.region_code = rg.region_code and travel_votes = "
			+ "( select max(travel_votes) from travel_informetion ) order by travel_code ";
	
	public void places(String place){		this.place = place;	}
	public String votesSQL = "update travel_informetion set travel_votes = travel_votes+1 where travel_place = ?";
	//지역, 홈
	
	
	//오픈데이터 베이스와 클로즈
	public Connection openDatabase(){
		try{Class.forName(DRV);
		return DriverManager.getConnection(URL);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return null;
	}
	public void close(Connection c, PreparedStatement p , ResultSet r){
		if(r != null) try{ r.close(); r= null; } catch (Exception e) {}
		if(p != null) try{ p.close(); p= null; } catch (Exception e) {}
		if(c != null) try{ c.close(); c= null; } catch (Exception e) {}
	}

	

}